package cn.edu.sptc.lichaoping.hellespring.runner;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;

@Slf4j
@Component
public class MyApplicationRunner implements ApplicationRunner {
    private static final Logger log = LoggerFactory.getLogger(MyApplicationRunner.class);

    @Override
    public void run(ApplicationArguments args) throws Exception {
//       log.info("这是一个应用程序运行器");
        log.info("应用冷启动完成报时，当前时间为："+ getDateTimeByLocalDateTime());
    }

    private String getDateTimeByLocalDateTime() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyy-MM-dd HH:mm:ss.SSS");
        return simpleDateFormat.format(System.currentTimeMillis());
    }
}